﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace MidimediaFinder
{
    [System.Xml.Serialization.XmlRootAttribute(Namespace = "",
                 IsNullable = false)]
    public class Result
    {
        public string message;
        public string err;
        public string lat;
        public string log;
        public List<item> items;
        public List<promotion> promotions;

        public Result()
        {
            message = "";
            err = "0";
            lat = "0";
            log = "0";
            items = new List<item>();
            promotions = new List<promotion>();

        }

        public void UpdateChars()
        {
            for (int i = 0; i < items.Count; i++)
            {
                var item = items[i];
                item.Description = Storage.CheckUtf8Chars(item.Description);

                for (int j = 0; j < item.Promotions.Count; j++)
                {
                    item.Promotions[j].Promotion_Description = Storage.CheckUtf8Chars(item.Promotions[j].Promotion_Description);
                    item.Promotions[j].Short_description = Storage.CheckUtf8Chars(item.Promotions[j].Short_description);
                }
            }

            for (int i = 0; i < promotions.Count; i++)
            {
                promotions[i].Promotion_Description = Storage.CheckUtf8Chars(promotions[i].Promotion_Description);
                promotions[i].Short_description = Storage.CheckUtf8Chars(promotions[i].Short_description);
                promotions[i].Description = Storage.CheckUtf8Chars(promotions[i].Description);
            }
        }

    }

    public class item
    {
        public string Id = "";
        public string Name = "";
        public string Adress = "";
        public string Latitude = "";
        public string Longitude = "";
        public string ImageUrl = "";
        public string Website = "";
        public string PhoneNumber = "";
        public string Description = "";
        public string Visible = "";
        public string Email = "";
        public string Pwd = "";
        public string Sessid = "";
        public string Type = "";
        public string Contract = "";
        public string RegisteredOn = "";
        public string Distance = "";
        public string ResultType = "";
        public string Type_Name = "";
        private string _Map = "";
        public string Map
        {
            get
            {
                return _Map;
            }
            set
            {
                var s = (string)value;
                s = s.Replace("_____", "&");
                _Map = s;
            }
        }
        public double Stars = 0;
        public List<promotion> Promotions = new List<promotion>();
        public List<comment> Comments = new List<comment>();
        public List<string> Images = new List<string>();
        public int Milliseconds = 0;
        public comment MyComment = null;
        public string FBName = "";
        public string FBUrl = "";
        public string TwitterName = "";
        public string TwitterUrl = "";
        public string RequestPwd = "";
        public string AllowComments = "";
        public string CommentsPwd = "";
    }

    public class promotion : item
    {
        public string POI_ID = "";
        public string StartOn = "";
        public string EndOn = "";
        public string Bonus = "";
        public string Bonus_desc = "";
        public string Short_description = "";
        public string POI = "";
        public string Duration = "";
        public string Promotion_Description = "";
        public string Hint = "";
        public string Icon = "";
        public string StartDate = "";
        public string EndDate = "";
        public string StartTime = "";
        public string EndTime = "";

        public promotion()
        {
        }
    }

    public class comment
    {
        public string Id = "";
        public string POI = "";
        public string Username = "";
        public int Stars = 0;
        public string Comment = "";
        public string PhoneId = "";
        public string Datetime = "";

        public comment()
        {
        }
    }
}
